<template>
    <view>
	
		<uni-section title="" subTitle="" type="line">
			<uni-notice-bar show-icon color="#2979FF" background-color="#EAF2FF" 
			scrollable show-get-more more-text="查看更多" moreColor="#2979FF"
			@getmore="getMore" showIcon="true" speed=30 @click="onClick"
			:text="noticeText" />
		</uni-section>
		
		<view class="grid bg-white col-3 guoshao-down-count">
			<view class="padding-sm guoshao-padding-sm-1">
				<view class=" padding radius text-center ">
					<view class="guoshao-money-new">总下载量</view>
					<view class="margin-top-sm text-red">{{resultData.sumDownCount}}</view>
				</view>
			</view>
			<view class="padding-sm guoshao-padding-sm-1">
				<view class=" padding radius text-center ">
					<view class="guoshao-money-new">昨日下载</view>
					<view class="margin-top-sm text-red">{{resultData.toDayDownCount}}</view>
				</view>
			</view>
			<view class="padding-sm guoshao-padding-sm-1">
				<view class=" padding radius text-center ">
					<view class="guoshao-money-new">今日下载</view>
					<view class="margin-top-sm text-red">{{resultData.toNowDownCount == undefined ? 0 : resultData.toNowDownCount}} </view>
				</view>
			</view>
		</view>
		
		<view class="grid col-4 bg-white  guoshao-down-money">
			<view class="padding-sm guoshao-padding-sm" >
				<view class="padding radius text-center light" >
					<view class="guoshao-money-new">累计</view>
					<view class="margin-top-sm text-price text-red">{{ sumMoney }}</view>
				</view>
			</view>
			<view class="padding-sm guoshao-padding-sm">
				<view class="padding radius text-center light" >
					<view class="guoshao-money-new">上月</view>
					<view class="margin-top-sm text-price text-red">{{ lastMonth }}</view>
				</view>
			</view>
			<view class="padding-sm guoshao-padding-sm">
				<view class="padding radius text-center light" >
					<view class="guoshao-money-new">本月</view>
					<view class="margin-top-sm text-price text-red">{{ thisMonth }}</view>
				</view>
			</view>
			<view class="padding-sm guoshao-padding-sm">
				<view class="padding radius text-center light" >
					<view class="guoshao-money-new">昨日</view>
					<view class="margin-top-sm text-price text-red">{{ yesterdayMoney }}</view>
				</view>
			</view>
		</view>
		
		<!-- <view class="cu-list grid col-4 guoshao-shouyi">
		    <view class="cu-item guoshao-money">
		        <view class="text-red">￥{{ sumMoney }}</view>
		        <text>累计</text>
		    </view>
		    <view class="cu-item guoshao-money">
		        <view class="text-red">￥{{ lastMonth }}</view>
		        <text>上月</text>
		    </view>
			<view class="cu-item guoshao-money">
			    <view class="text-red">￥{{ thisMonth }}</view>
			    <text>本月</text>
			</view>
			<view class="cu-item guoshao-money">
			    <view class="text-red">￥{{ yesterdayMoney }}</view>
			    <text>昨日收益</text>
			</view>
		</view> -->
		
		<!-- <view class="guoshao-tishi">温馨提示：数据同步存在滞后性，实际收入请以结算单为准</view> -->
		
		
        <view class="cu-list menu sm-border card-menu margin-top">
            <view class="cu-item">
                <view class="content padding-tb-sm">
                    <view class="guoshao-font-weight">
                        <text class="text-blue margin-right-xs"></text>
                        待结算
                    </view>
                    <view class="text-black text-sm">
                        <text class="margin-right-xs"></text>
                        抖音均为次日结算前日ECPM价格
                    </view>
                </view>
            </view>
            <view class="cu-item" @click.stop.prevent="" data-link="/pages_user/adprofit/sumprofit" data-status="1">
                <view class="content padding-tb-sm">
                    <text class="text-black"></text>
                    <text class="text-black">广告</text>
                </view>
                <view class="action">
                    <text class="text-red text-sm">{{ count }}</text>
                </view>
            </view>
			<view class="cu-item" @click.stop.prevent="" data-link="/pages_profit/adprofit/sumprofit" data-status="1">
			    <view class="content padding-tb-sm">
			        <text class="text-black"></text>
			        <text class="text-black">邀请</text>
			    </view>
			    <view class="action">
			        <text class="text-red text-sm">{{ rewardCount }}</text>
			    </view>
			</view>
        </view>

        <view class="cu-list menu sm-border card-menu margin-top">
            <view class="cu-item">
                <view class="content padding-tb-sm">
                    <view class="guoshao-font-weight">
                        <text class="text-blue margin-right-xs"></text>
                        待入账
                    </view>
                    <!--
            <view class="text-black text-sm">
                <text class="margin-right-xs"></text> 2021-09-05至2021-10-15
            </view>
            -->
                </view>
            </view>
            <view class="cu-item arrow" @click.stop.prevent="jumpClick" data-link="/pages_profit/adprofit/sumprofit" data-status="2" data-dtype="1">
                <view class="content padding-tb-sm">
                    <text class="text-black"></text>
                    <text class="text-black">广告</text>
                </view>
                <view class="action">
                    <text class="text-red text-sm">￥{{ toSettled }}</text>
                </view>
            </view>
			<view class="cu-item arrow" @click.stop.prevent="jumpClick" data-link="/pages_profit/adprofit/sumprofit" data-status="2" data-dtype="2">
			    <view class="content padding-tb-sm">
			        <text class="text-black"></text>
			        <text class="text-black">邀请</text>
			    </view>
			    <view class="action">
			        <text class="text-red text-sm">￥{{ rewardSett }}</text>
			    </view>
			</view>
        </view>

        <view class="cu-list menu sm-border card-menu margin-top">
            <view class="cu-item">
                <view class="content padding-tb-sm">
                    <view class="guoshao-font-weight">
                        <text class="text-blue margin-right-xs"></text>
                        已入账
                    </view>
                </view>
            </view>
            <view class="cu-item arrow" @click.stop.prevent="jumpClick" data-link="/pages_profit/adprofit/sumprofit" data-status="3" data-dtype="1">
                <view class="content padding-tb-sm">
                    <text class="text-black"></text>
                    <text class="text-black">广告</text>
                </view>
                <view class="action">
                    <text class="text-red text-sm">￥{{ paid }}</text>
                </view>
            </view>
			<view class="cu-item arrow" @click.stop.prevent="jumpClick" data-link="/pages_profit/adprofit/sumprofit" data-status="3" data-dtype="2">
			    <view class="content padding-tb-sm">
			        <text class="text-black"></text>
			        <text class="text-black">邀请</text>
			    </view>
			    <view class="action">
			        <text class="text-red text-sm">￥{{ rewardPay }}</text>
			    </view>
			</view>
        </view>
    </view>
</template>

<script>
	

const http = require('../../../utils/http.js');

export default {
	components:{
	},
    data() {
        return {
            settled: 0,
            toSettled: 0, //广告已结算
            paid: 0,  //广告已打款
            count: 0, //下载次数
			rewardCount:0,//奖励次数
			rewardSett:0,//奖励 已结算
			rewardPay:0 ,//奖励已打款
			sumMoney:0, //总收益
			yesterdayMoney:0, //昨日收益
			lastMonth:0, //上月收益
			thisMonth:0,//本月收益
			noticeText:'',
			noticeId:0,
			resultData:null
        };
    },
    onLoad: function (options) {
        let that = this;
		this.loadProfit();
		
		that.notices();
    },
	onShow: function (){
		this.userInfoBal();
	},
	onPullDownRefresh:function() {
		let that = this ;
		setTimeout(function () {
			that.loadProfit();
			uni.stopPullDownRefresh();
		}, 1000);
	},
    methods: {
		getMore() {
			uni.navigateTo({
				url:'../../../pages_user/notice/notice'
			})
		},
		onClick:function(){
			uni.navigateTo({
				url:'/pages/notice/notice?id='+this.noticeId
			})
		},
		userInfoBal:function(){
			let that = this;
			uni.showLoading({
			    title: '加载中'
			});
			
			var params = {
			    url: '/p/balance/userInfoBal',
			    method: 'get',
				//baseUrl:true,
			    data: {},
			    callBack: function (res) {
					console.log(res.data)
			        uni.hideLoading();
			        if (res.code == 200) {
			            that.userInfo = res.data;
			        } else {
			            uni.showToast({
			                title: res.msg,
			                duration: 2000,
			                icon: 'none'
			            });
			        }
			    }
			};
			http.request(params);
		},
		notices: function () {
		    let that = this;
		    var params = {
		        url: '/notice/notices',
		        method: 'GET',
		        data: {
		            type: 2
		        },
		        callBack: function (res) {
					if(res.data.length > 0){
						let noticesa = [];
						for (var i = 0; i < res.data.length; i++) {
							if(i == 0){
								that.noticeText = res.data[i].abstractText;
								that.noticeId = res.data[i].id;
							}else{
								break;
							}
						}
						
					}
		        }
		    };
		    http.request(params);
		},
        jumpClick: function (e) {
            let link = e.currentTarget.dataset.link;
            let status = e.currentTarget.dataset.status;
			let dtype = e.currentTarget.dataset.dtype;
            link = link + '?status=' + status + "&dtype="+dtype;
            console.log(e);
            uni.navigateTo({
                url: link,
                // 指定页面的 url
                success: (res) => {},
                fail: (res) => {
                }
            });
        },

        loadProfit: function () {
			
            let that = this;
			
			uni.showLoading({
				title:'加载中'
			})
			
            var params = {
                url: '/p/balance/profit',
                method: 'GET',
                data: {
                },
                callBack: function (res) {
                    that.setData({
                        //settled: res.data.settled,
                        toSettled: res.data.toSettled,
                        paid: res.data.paid,
                        count: res.data.count,
						rewardCount:res.data.rewardCount,
						rewardSett:res.data.rewardSett,
						rewardPay:res.data.rewardPay,
						sumMoney:res.data.sumMoney,
						yesterdayMoney:res.data.yesterdayMoney,
						lastMonth:res.data.lastMonth,
						thisMonth:res.data.thisMonth,
						resultData:res.data
                    });
					uni.hideLoading();
                }
            };
            http.request(params);
        }
    }
};
</script>
<style>
@import './record.css';

/* 
.ns {
	width: 100%;
	height: 60px;
	text-align: center;
	line-height: 200rpx;
	color: white;
	font-size: 34rpx;
	font-weight: bold;
	background: linear-gradient(to right, #ff8440, #ff1e0f);
}
.top {
	margin-top: 20rpx;
}
.flexView {
	width: 100%;
	height: 100%;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	.scrollView {
		width: 100%;
		height: 100%;
		flex: 1;
		overflow-y: auto;
		overflow-x: hidden;
		position: relative;
		// padding-bottom: 116rpx;
		.head-read {
			padding-bottom: 30rpx;
			.flex {
				display: flex;
				align-items: center;
				padding: 50rpx;
				position: relative;
				.read-img {
					width: 120rpx;
					height: 120rpx;
					border-radius: 100%;
					overflow: hidden;
					margin-right: 20rpx;
					border: 4rpx solid rgba(255, 255, 255, 0.3);
				}
				.flex-box {
					flex: 1;
					min-width: 0;
					font-size: 26rpx;
					color: #333;
					&-text {
						margin: 10rpx 0;
						color: #f5f5f5;
						font-weight: normal;
					}
				}
				.arrow {
					position: relative;
					padding-right: 30rpx;
					span {
						font-size: 28rpx;
						color: white;
					}
					&:after {
						content: ' ';
						display: inline-block;
						height: 12rpx;
						width: 12rpx;
						border-width: 4rpx 4rpx 0 0;
						border-color: #848484;
						border-style: solid;
						transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
						position: relative;
						top: -4rpx;
						position: absolute;
						top: 50%;
						margin-top: -8rpx;
						right: 4rpx;
						border-radius: 2rpx;
					}
				}
				.arrow-one:after {
					border-color: white;
					margin-top: -6rpx;
				}
			}
		}
		.white-box {
			width: 92%;
			background: white;
			border-radius: 10rpx;
			margin: -120rpx auto 20rpx;
			box-shadow: 0 6rpx 20rpx #e7e7e7;
			.tx {
				padding-top: 26rpx;
				overflow: hidden;
				display: flex;
				justify-content: space-between;
				align-content: center;
				&-grid {
					box-sizing: border-box;
					&:first-child {
						margin-left: 40rpx;
					}
					&-comm-sign {
						display: block;
						border-radius: 40rpx 0 0 40rpx;
						font-size: 26rpx;
						padding: 16rpx 44rpx;
						background: linear-gradient(to right, #fef082, #ffc551);
						background-color: #fef082;
						color: #cf4400;
					}
					&-text {
						display: block;
						color: #333;
						font-size: 26rpx;
						white-space: nowrap;
						text-overflow: ellipsis;
						overflow: hidden;
						.title {
							font-size: 26rpx;
							font-weight: normal;
							color: #ff6423;
						}
						.money {
							font-size: 60rpx;
							color: #ff6423;
							letter-spacing: 2rpx;
							margin-bottom: 10rpx;
							&-b {
								font-size: 28rpx;
							}
						}
					}
				}
			}
			.palace {
				padding-bottom: 20rpx;
				overflow: hidden;
				display: flex;
				justify-content: center;
				&-grid {
					flex: 1;
					position: relative;
					box-sizing: border-box;
					&:not(:last-child) {
						&:after {
							width: 1rpx;
							height: 80rpx;
							background: #fddece;
							content: ' ';
							display: inline-block;
							position: absolute;
							top: 0;
							right: 0;
						}
					}
					&-text {
						display: block;
						text-align: center;
						color: #333;
						font-size: 32rpx;
						white-space: nowrap;
						text-overflow: ellipsis;
						overflow: hidden;
						&-name {
							font-size: 26rpx;
							font-weight: normal;
							color: #ff8a4a;
						}
						&-data {
							font-size: 32rpx;
							color: #ff8a4a;
							letter-spacing: 2rpx;
							margin-bottom: 5rpx;
							&-b {
								font-size: 20rpx;
							}
						}
					}
				}
			}
		}
	}
} */
</style>
